#ifndef GAME_OBJECT_FACTORY_H
#define GAME_OBJECT_FACTORY_H
#include "GameObject.h"
#include "Singleton.h"
#include <map>
#include <assert.h>



class GameObjectFactory : public Uncopyable
{
public:
	typedef GameObject* (*Creator) ();
	typedef std::map<std::string, Creator> FactoryMap;
	GameObject* Create(const std::string& typeName)
	{
		Creator c = m_map[typeName];
		assert (c != 0);
		return c();
	}

	bool AddToMap(const std::string& typeName, Creator c)
	{
		m_map[typeName] = c;
		return true;
	}
private:
	GameObjectFactory() {}
	friend class Singleton<GameObjectFactory>;
	FactoryMap m_map;
};
typedef Singleton<GameObjectFactory> ObjectFactory;
#endif